#pragma once
#include "d3dutil.h"
#include "LevelElement.h"
#include "Vertex.h"
#include <vector>


class Sphere : public LevelElement
{
public:
	Sphere(const tstring &texfilename, float radius, UINT numSlices=8, UINT numStacks=8, float UScale=1, float VScale=1);
	~Sphere();

	virtual void Initialize(ContentManager *pContentManager);
	virtual void Tick(const InputState & refInputState){}
	virtual void Draw(const RenderContext* pRenderContext, ID3D10ShaderResourceView* shadowdepthmap = 0);
	void SetEffect(ID3D10Effect* effect);

protected:
	vector<VertexPosNormTex> m_VecVertices;
	vector<DWORD> m_VecIndices;

	void BuildStacks(vector<VertexPosNormTex>& vertices, vector<DWORD>& indices);
	void DefineInputlayout();
	void CreateEffect(ContentManager *pContentManager);

	ID3D10InputLayout*			m_pVertexLayout;
	ID3D10Buffer*				m_pVertexBuffer;
	ID3D10Buffer*				m_pIndexBuffer;
	ID3D10ShaderResourceView *	m_pTextureRV;
	ID3D10Effect*				m_pDefaultEffect;
	ID3D10EffectTechnique*		m_pDefaultTechnique;

	ID3D10EffectMatrixVariable* m_pWorldViewProjectionVariable;
	ID3D10EffectMatrixVariable* m_pWorldVariable;
	ID3D10EffectShaderResourceVariable* m_pDiffuseMapVariabele;

	UINT m_VertexBufferStride;
	tstring m_TextureName;

	UINT m_NumIndices;
	float m_Radius;
	UINT  m_NumSlices;
	UINT  m_NumStacks;
	float m_UScale;
	float m_VScale;

private:
	void FillVertexAndIndexBuffer();
	void GetEffectVariables(ID3D10Effect* pEffect);
	// -------------------------
	// Disabling default copy constructor and default assignment operator.
	// If you get a linker error from one of these functions, your class is internally trying to use them. This is
	// an error in your class, these declarations are deliberately made without implementation because they should never be used.
	// -------------------------
	Sphere(const Sphere& t);
	Sphere& operator=(const Sphere& t);
};

